package com.yohann.designPattern.visitor;

import java.util.LinkedList;
import java.util.List;

/**
 * <p>
 *
 * </p>
 *
 * @author Yohann
 * @since 2021/2/11 17:02
 */
public class ObjectStructure {
    private List<Person> people = new LinkedList<>();

    public void attach(Person person) {
        people.add(person);
    }

    public void detach(Person person) {
        people.remove(person);
    }

    public void display(Action action) {
        for (Person person : people) {
            person.accept(action);
        }
    }
}